package netty.dubbo.client.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author: 程序员七哥
 * @date: 2021-12-19
 * @description: 客户端处理器，用来进行 Rpc 调用
 */
public class RpcClientHandler extends SimpleChannelInboundHandler {

    private Object result;

    public Object getResult() {
        return result;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object o) throws Exception {
        // 将调用服务端执行的方法结果进行输出
        this.result = o;
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }
}
